<?php include("header.php"); ?>

<script type="text/javascript">
    function validate()
	{
        var name = document.getElementById('name');
		var country = document.getElementById('country');
        
        if(isEmptyTextBox(country, '<?php echo _MSG_COUNTRY_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        if(isEmptyTextBox(name, '<?php echo _MSG_NAME_NOT_EMPTY; ?>'))
        {
            return false;
        }
        
        var agr = new Array();
        agr.push(trim(name.value));
        agr.push('<?php echo $port->id;?>');
        agr.push(country.value);

        if(callFunction("Port::isExistsByName", agr)=='1')
        {
            showErrorBubble(name, '<?php echo _MSG_PORT_NAME_EXISTS; ?>');
            return false;
        }
        
		document.port.submit();
	}
    
    /*function displayRegion(id_country) {
        var agr = new Array();
        agr.push(id_country);
        
        if((data=callFunction("Region::getRegionByCountry", agr)))
        {
            jQuery('#reg').html(data);
        }
    }*/

</script>

	<div class="one_center">
		<div class="box_two_third">
			<div class="box_head"><?php if($port->id) { echo _LB_EDIT_PORT; } else { echo _LB_ADD_PORT; } ?></div>
			<div class="box_content" >
				<form action="" name="port" method="post">
				<input type="hidden" id="id" name="id" value="<?php $port->id; ?>"/>
				<input type="hidden" id="act" name="act" value="<?php echo ACT_VALID_EDIT; ?>"/>
				<table cellpadding="0" cellspacing="5px" border="0">
                    <tr>
                        <td width="20%"><?php echo _LB_NATIONALITY; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></td>
                        <td>
                            <select id="country" name="country" style="width: 180px;">
                                <option value=""><?php echo _LB_CHOOSE; ?></option>
                                <?php while($country->fetchNext()) { ?>
                                   <option value="<?php echo $country->id; ?>" <?php if($country->id == $port->id_wp_country) {?>selected="true"<?php }?>><?php echo $country->name; ?></option>
                                <?php } ?>
                            </select>
                        </td>
                    </tr>
					<tr>
						<td width="20%"><label><?php echo _LB_PORT_NAME; ?>&nbsp;:&nbsp;<?php echo _LB_REQUIRE_FIELD; ?></label></td>
                        <td><input name="name" id="name" type="text" size="<?php echo SIZE_NAME; ?>" maxlength="<?php echo MAX_LENGTH_NAME;?>" value="<?php echo $port->name; ?>"/></td>
					</tr>
					
                    <tr>
					  	<td class="submit" colspan="2" style="padding-top: 10px;">
							  <a id="auto_port_return" class="tribullet" id="btnReturn" href="<?php echo $backlink; ?>"><?php echo _LB_BACK; ?></a>
							  <a id="auto_port_validate" class="tribullet" href="#" onclick="validate()"><?php echo _LB_VALIDATE; ?></a>
						</td>
					</tr>
				</table>
				</form>
			</div>
		</div>
	</div>

<?php include("footer.php"); ?>

